/**
 * 
 */
package com.feib.stms.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.feib.stms.dao.TempUploadFileErrorDao;
import com.feib.stms.model.TempUploadFileError;
import com.feib.stms.pagination.PaginatedList;
import com.feib.stms.service.TempUploadFileErrorService;
import com.feib.stms.util.UserUtil;

/**
 * @author Jimmy Liu
 *
 */
@Service("tempUploadFileErrorService")
public class TempUploadFileErrorServiceImpl extends BaseServiceImpl implements TempUploadFileErrorService {

	private static final long serialVersionUID = -5015929703065336658L;

	@Resource(name="tempUploadFileErrorDao")
	private TempUploadFileErrorDao tempUploadFileErrorDao;

	public int addTempUploadFileError(TempUploadFileError tempUploadFileError)
	{
		Date now = new Date();
		tempUploadFileError.setCreatedDate(now);
		tempUploadFileError.setCreatedBy(UserUtil.getUserGroup().getGroupNo()+"_"+UserUtil.getUserId());
		tempUploadFileError.setUpdatedDate(now);
		tempUploadFileError.setUpdatedBy(UserUtil.getUserGroup().getGroupNo()+"_"+UserUtil.getUserId());

		return this.tempUploadFileErrorDao.insert(tempUploadFileError);		
	}

	public int addTempUploadFileErrors(List<TempUploadFileError> tempUploadFileErrors)
	{
		Date now = new Date();
		String updateBy = UserUtil.getUserGroup().getGroupNo()+"_"+UserUtil.getUserId();
		for(TempUploadFileError tempUploadFileError : tempUploadFileErrors)
		{
			tempUploadFileError.setCreatedDate(now);
			tempUploadFileError.setCreatedBy(updateBy);
			tempUploadFileError.setUpdatedDate(now);
			tempUploadFileError.setUpdatedBy(updateBy);
		}
		int updateCount = this.tempUploadFileErrorDao.insert(tempUploadFileErrors);	

		return 	updateCount;
	}

	public int deleteByTempUploadFilePk(Long tempUploadFilePk) {
		return tempUploadFileErrorDao.deleteByTempUploadFilePk(tempUploadFilePk);
	}

	public PaginatedList<TempUploadFileError> findPaginatedListByTempUploadFilePk(
			Long tempUploadFilePk,
			PaginatedList<TempUploadFileError> qryCondition) {
		return tempUploadFileErrorDao.queryPaginatedListByTempUploadFilePk(tempUploadFilePk, qryCondition);
	}

}
